package com.jr.service.impl;

import com.jr.entry.BookInfo;
import com.jr.entry.Users;
import com.jr.mapper.UsersMapper;
import com.jr.pojo.BookInfoSelect;
import com.jr.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(propagation = Propagation.REQUIRED)
public class UsersServiceImpl implements UsersService {
    @Autowired
    private UsersMapper usersMapper;

    @Override    //登录
    public Users login(Users users) {
        return usersMapper.selectByInfo(users);
    }

    @Override
    public List<BookInfo> findAll() {
        return usersMapper.selectAll();
    }

    @Override
    public List<BookInfo> findByBy(BookInfoSelect bookInfo) {
        return usersMapper.selectByBy(bookInfo);
    }

    @Override
    public boolean addBook(BookInfo bookInfo) {
        return usersMapper.insertBook(bookInfo)>0?true:false;
    }

    @Override
    public boolean updBook(BookInfo bookInfo) {
        return usersMapper.updateBook(bookInfo)>0?true:false;
    }

    @Override
    public boolean delBook(Integer book_id) {
        return usersMapper.deleteBook(book_id)>0?true:false;
    }

    @Override
    public List<BookInfo> findByPage(int page,int pageSize) {
        int offset = (page -1) * pageSize;
        return usersMapper.selectByPage(offset,pageSize);
    }

}
